home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / PInterfaces / ErrMgr.p < prev    next >
Encoding:
Text File  |  1996-09-18  |  3.8 KB  |  109 lines  |  [TEXT/MPS ]

  1. {
  2.     File:        ErrMgr.p
  3.  
  4.     Copyright:    © 1987-88, 1993-95 by Apple Computer, Inc.
  5.                 All rights reserved.
  6.  
  7.     Version:    3.4a4
  8.     Created:    Tuesday, March 30, 1993 18:00
  9.  
  10.     07/21/95    DGD    Removing LibExport directives.  ToolLibs is a static library
  11.                                 in all environments.
  12. }
  13.  
  14. {$IFC UNDEFINED UsingIncludes}
  15. {$SETC UsingIncludes := 0}
  16. {$ENDC}
  17.  
  18. {$IFC NOT UsingIncludes}
  19.     UNIT ErrMgr;
  20.     INTERFACE
  21. {$ENDC}
  22.  
  23. {$IFC UNDEFINED UsingErrMgr AND UNDEFINED __ERRMGR__}
  24. {$SETC UsingErrMgr := 1}
  25. {$SETC __ERRMGR__ := 1}
  26.  
  27. {$I+}
  28. {$SETC ErrMgrIncludes := UsingIncludes}
  29. {$SETC UsingIncludes := 1}
  30. {$IFC UNDEFINED UsingTypes AND UNDEFINED __TYPES__}
  31. {$I Types.p}
  32. {$ENDC}
  33. {$SETC UsingIncludes := ErrMgrIncludes}
  34.  
  35.  
  36. PROCEDURE InitErrMgr(toolErrFilename: Str255;sysErrFilename: Str255;showToolErrNbrs: BOOLEAN);
  37.  
  38. { ErrMgr initialization.This must be done before using any other ErrMgr
  39. routine.  Set showToolErrNbrs to true if you want all tool messages to contain
  40. the error number following the message text enclosed in parentheses (e.g.,
  41. "<msg txt> ([OS] Error <n>)"; system error messages always contain the error
  42. number).  The toolErrFileName parameter is used to specify the name of a
  43. tool-specific error file, and should be the NULL or a null string if not used
  44. (or if the tool's data fork is to be used as the error file, see
  45. GetToolErrText for futher details). The sysErrFileName parameter is used to
  46. specify the name of a system error file, and should normally be the NULL or a
  47. null string, which causes the ErrMgr to look in the MPW Shell directory for
  48. "SysErrs.Err" (see GetSysErrText). }
  49.  
  50.  
  51. PROCEDURE CloseErrMgr; C;
  52.  
  53. { Ideally a CloseErrMgr should be done at the end of execution to make sure all
  54. files opened by the ErrMgr are closed.    You can let normal program termination
  55. do the closing.  But if you are a purist...
  56.  }
  57.  
  58.  
  59. PROCEDURE GetSysErrText(msgNbr: INTEGER;errMsg: StringPtr);
  60.  
  61. (* Get the error message text corresponding to system error number errNbr from
  62. the system error message file (whose name was specified in the InitErrMgr
  63. call).    The text of the message is returned in errMsg and the function returns
  64. a pointer to errMsg.  The maximum length of the message is limited to 254
  65. characters.
  66.  
  67. Note, if a system message filename was not specified to InitErrMgr, then the
  68. ErrMgr assumes the message file contained in the file "SysErrs.Err".  This
  69. file is first accessed as "                                 {ShellDirectory}SysErrs.Err" on the assumption that
  70. SysErrs.Err is kept in the same directory as the MPW Shell.  If the file
  71. cannot be opened, then an open is attempted on "SysErrs.Err" in the System
  72. Folder. *)
  73.  
  74.  
  75. PROCEDURE AddErrInsert(insert: Str255;msgString: StringPtr); C;
  76.  
  77. { Add another insert to an error message string.This call is used when more
  78. than one insert is to be added to a message (because it contains more than
  79. one '^' character).
  80.  }
  81.  
  82.  
  83. PROCEDURE GetToolErrText(msgNbr: INTEGER;errInsert: Str255;errMsg: StringPtr);
  84.  
  85. (* Get the error message text corresponding to tool error number errNbr from
  86. the tool error message file (whose name was specified in the InitErrMgr
  87. call).    The text of the message is returned in errMsg and the function returns
  88. a pointer to errMsg.  The maximum length of the message is limited to 254
  89. characters.  If the message is to have an insert, then ErrInsert should be a
  90. pointer to it.    Otherwise it should be either be a null string or a NULL
  91. pointer.
  92.  
  93. Inserts are indicated in error messages by specifying a '^' to indicate where
  94. the insert is to be placed.
  95.  
  96. Note, if a tool message filename was not specified to InitErrMgr, then the
  97. ErrMgr assumes the message file contained in the data fork of the tool calling
  98. the ErrMgr.  This name is contained in the Shell variable    {Command} and the
  99. value of that variable is used to open the error message file. *)
  100.  
  101.  
  102.  
  103. {$ENDC}    { UsingErrMgr }
  104.  
  105. {$IFC NOT UsingIncludes}
  106.     END.
  107. {$ENDC}
  108.  
  109.